package com.huanghwh.sync.core.schedule;

import com.huanghwh.sync.core.service.ITableSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

/**
 * @Author: huanghwh
 * @Date: 2021/12/21 15:17
 * @Description: db同步定时任务
 */
@Configuration
@EnableScheduling
@Slf4j
public class SyncSchedule {

    @Autowired
    private ITableSyncService tableSyncService;


    @Scheduled(cron = "0 0/5 * * * ?")
    private void configureTasks() {
        log.info("=============== 同步任务开始：{} =================", new Date());
        // 同步分钟要求与定时任务频率一直
        tableSyncService.startSync(-5);
        log.info("=============== 同步任务结束：{} =================", new Date());
    }

}


